package com.hose.biz;

import com.hose.pages.ExpenseCenterNewPage;
import com.microsoft.playwright.Page;

/**
 * 自建应用
 */
public class ExpenseCenterNewBiz {
    private Page page;
    private ExpenseCenterNewPage expenseCenterNewPage;

    public ExpenseCenterNewPage getExpenseCenterNewPage() {
        return expenseCenterNewPage;
    }

    private ExpenseCenterNewBiz(Page page) {
        this.page = page;
        this.expenseCenterNewPage = ExpenseCenterNewPage.build(page);
    }

    public static ExpenseCenterNewBiz build(Page page) {
        return new ExpenseCenterNewBiz(page);
    }

    /**
     * 创建 自定义应用
     * @param applicationName
     * @return
     */
    public ExpenseCenterNewBiz createApplicationNotExists(String applicationName) {
        //进入合思 +
        this.expenseCenterNewPage.goHome();
        //搜索是否存在
        if (!this.expenseCenterNewPage.seachApplication(applicationName)) {
            // 不存在则创建
            this.expenseCenterNewPage.createCustomApplicaiton(applicationName);
        }
        return this;
    }

    public ExpenseCenterNewBiz createBizObject(String applicationName, String bizObjectName) {
        //进入合思 +
        this.expenseCenterNewPage.goHome();
        this.expenseCenterNewPage.seachApplication(applicationName);
        this.expenseCenterNewPage.enterApplication(applicationName);
        return this;
    }
}
